package com.erp.erp_servers.bill_exchange.Imp;


import com.erp.erp_dao.BillExchangeInfo.IBillExchangeProductPartsDao;
import com.erp.erp_entitys.BillExchangeInfo.BillExchangeProductParts;
import com.erp.erp_servers.bill_exchange.BillExchangeProductPartsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;

/**
 * 结汇产品配件明细表(BillExchangeProductParts)表服务实现类
 *
 * @author makejava
 * @since 2021-01-15 21:13:36
 */
@Service("billExchangeProductPartsService")
public class BillExchangeProductPartsServiceImpl implements BillExchangeProductPartsService {
    @Resource
    private IBillExchangeProductPartsDao billExchangeProductPartsDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public BillExchangeProductParts queryById(Integer id) {
        return this.billExchangeProductPartsDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<BillExchangeProductParts> queryAllByLimit(int offset, int limit) {
        return this.billExchangeProductPartsDao.queryAllByLimit(offset, limit);
    }

    @Override
    public List<BillExchangeProductParts> queryAllByLimit(BillExchangeProductParts parts) {
        return this.billExchangeProductPartsDao.queryAll(parts);
    }

    /**
     * 新增数据
     *
     * @param billExchangeProductParts 实例对象
     * @return 实例对象
     */
    @Override
    public BillExchangeProductParts insert(BillExchangeProductParts billExchangeProductParts) {
        this.billExchangeProductPartsDao.insert(billExchangeProductParts);
        return billExchangeProductParts;
    }

    /**
     * 修改数据
     *
     * @param billExchangeProductParts 实例对象
     * @return 实例对象
     */
    @Override
    public BillExchangeProductParts update(BillExchangeProductParts billExchangeProductParts) {
        this.billExchangeProductPartsDao.update(billExchangeProductParts);
        return this.queryById(billExchangeProductParts.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.billExchangeProductPartsDao.deleteById(id) > 0;
    }

    @Override
    public BigDecimal selectLastAmount(BillExchangeProductParts pro) {
        return billExchangeProductPartsDao.selectLastAmount(pro);
    }
}